Skip to content

feat(metrics): Add artifact_type tag to processing duration metric#577

Merged
NicoHinderling merged 3 commits intomainfrom
feat/artifact-type-timing-tag
Mar 9, 2026
Merged

feat(metrics): Add artifact_type tag to processing duration metric#577
NicoHinderling merged 3 commits intomainfrom
feat/artifact-type-timing-tag

Conversation

@NicoHinderling
Copy link
Contributor

Add artifact_type tag to the artifact.processing.duration statsd metric so we can break down processing time by artifact type (xcarchive, apk, aab) in Datadog dashboards.

The artifact type isn't available when timing starts — it's determined later inside process_artifact after download and parsing. To solve this, the statsd.timed context manager is replaced with a manual statsd.timing() call emitted in a finally block where the artifact type is known. Both emit the same timer metric type in Datadog, so existing dashboards are unaffected.

Changes:

  • Extract _get_artifact_type from nested function in _prepare_update_data to module-level so both process_artifact and _prepare_update_data can use it
  • process_artifact now returns the artifact type string
  • process_message captures the return value and emits statsd.timing() with the new artifact_type tag in a finally block
  • Uses time.monotonic() to match statsd.timed internal behavior, started at the same position in the ExitStack

Replace statsd.timed context manager with manual statsd.timing call
so artifact_type can be included in the metric tags. The artifact type
is only known after parsing inside process_artifact, which happens
after the timing context manager was set up.

Extract _get_artifact_type to module level so both process_artifact
and _prepare_update_data can use it. process_artifact now returns the
artifact type string, captured in process_message for the metric.

Uses time.monotonic() to match statsd.timed internal behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
@NicoHinderling NicoHinderling marked this pull request as ready for review March 6, 2026 17:33
…e tag

ArtifactType enum members have integer values (0, 1, 2), so .value
produces tags like artifact_type:0. Use .name.lower() to get
human-readable tags like artifact_type:xcarchive.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry
Copy link
Contributor

sentry bot commented Mar 6, 2026

Sentry Build Distribution

App Version Configuration
Hacker News 1.0.2 (13) Release

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

DogStatsd is instantiated with use_ms=False (default), so timed()
sent elapsed time in seconds. The * 1000 conversion to milliseconds
would inflate metric values 1000x, breaking existing dashboards.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry
Copy link
Contributor

sentry bot commented Mar 6, 2026

Sentry Build Distribution

App Version Configuration
Hacker News 1.0.2 (13) Release

@NicoHinderling NicoHinderling merged commit 89c34cf into main Mar 9, 2026
20 of 21 checks passed
@NicoHinderling NicoHinderling deleted the feat/artifact-type-timing-tag branch March 9, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants